package recite.word.service.base.common.enums;

import lombok.Getter;

import java.util.Optional;
import java.util.stream.Stream;

@Getter
public enum MonthEnum {
    JANUARY(0,"January"),
    FEBRUARY(1,"February"),
    MARCH(2,"March"),
    APRIL(3,"April"),
    MAY(4,"May"),
    JUNE(5,"June"),
    JULY(6,"July"),
    AUGUST(7,"August"),
    SEPTEMBER(8,"September"),
    OCTOBER(9,"October"),
    NOVEMBER(10,"November"),
    DECEMBER(11,"December");

    private Integer type;
    private String desc;

    MonthEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static MonthEnum getByType(Integer type){
        return Optional.ofNullable(type)
                .map(paramType -> Stream.of(values()).filter(item -> item.getType().equals(paramType)).findAny().orElse(null))
                .orElse(null);
    }
}
